package com.neusoft.yuejian12.yuejian_12.activity;

import android.app.Activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.neusoft.yuejian12.yuejian_12.R;
import com.neusoft.yuejian12.yuejian_12.adapter.TrainListAdapter;
import com.neusoft.yuejian12.yuejian_12.javabean.TrainBean;
import com.neusoft.yuejian12.yuejian_12.listener.RetrofitListener;
import com.neusoft.yuejian12.yuejian_12.model.TrainModel;

import java.util.List;

public class TrainRumenActivity extends Activity implements View.OnClickListener,RetrofitListener<List<TrainBean>> {
    private ImageView left_trainlist;
    private ImageView t_picture;
    private TextView t_name;
    private TrainListAdapter adapter;
    private RecyclerView recyclerView;
    private LayoutInflater mLayoutInflater;
    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_train_rumen);
        initView();
        initEvent();
        getTrainlista();
    }

    private void initView() {
        recyclerView = (RecyclerView) findViewById(R.id.rv_rumen);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));//设置布局

        left_trainlist = (ImageView) findViewById(R.id.left_trainlist);

    }
    private void initEvent() {
        //返回上一页
        left_trainlist.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });


    }
    void getTrainlista(){
        TrainModel trainModel=new TrainModel();
        trainModel.getTrainlista(this);
    }

    @Override
    public void onSuccess(List<TrainBean> trainBean){
        adapter = new TrainListAdapter(TrainRumenActivity.this,trainBean);
        recyclerView.setAdapter(adapter);
    }

    @Override
    public void onFail() {
        //showToast("网络发生错误");
    }
    @Override
    public void onClick(View view) {

    }


    }
